<?php
if (!defined('IN_RJ_ADMIN')) die("Error 404");

if ($level != 1) {
	echo $lang_acp['u_not_enter'];
	exit();
}

$mod_permission = acp_get_mod_permission();

$permission_list = array(
	'add_cat'	=>	$lang_acp['add_cat'],
	'edit_cat'	=>	$lang_acp['manager_cat'],
	'del_cat'	=>	$lang_acp['del_cat'],
	'add_media'	=>	$lang_acp['add_media'],
	'edit_media'	=>	$lang_acp['manager_media'],
	'del_media'	=>	$lang_acp['del_media'],
	'add_singer'	=>	$lang_acp['add_singer'],
	'edit_singer'	=>	$lang_acp['manager_singer'],
	'del_singer'	=>	$lang_acp['del_singer'],
	'add_news'	=>	$lang_acp['add_news'],
	'edit_news'	=>	$lang_acp['manager_news'],
	'del_news'	=>	$lang_acp['del_news'],
	'add_user'	=>	$lang_acp['add_user'],
	'edit_user'	=>	$lang_acp['manager_user'],
	'del_user'	=>	$lang_acp['del_user'],
	'add_link'	=>	$lang_acp['add_ads'],
	'edit_link'	=>	$lang_acp['manager_ads'],
	'del_link'	=>	$lang_acp['del_ads'],
	'add_template'	=>	$lang_acp['add_tpl'],
	'edit_template'	=>	$lang_acp['manager_tpl'],
	'del_template'	=>	$lang_acp['del_tpl'],
	'edit_request'	=>	$lang_acp['manager_request'],
);

if (!$_POST['submit']) {
?>
<form method=post>
<table class=border cellpadding=2 cellspacing=0 width=95%>
<tr><td colspan=2 class=title align=center><?=$lang_acp['set_mod_per']?></td></tr>

<?php
foreach ($permission_list as $name => $desc) {
?>
<tr>
	<td class=fr width=30%><b><?=$desc?></b></td>
	<td class=fr_2><input type=radio class=checkbox value=1 name=<?=$name?><?=(($mod_permission[$name])?' checked':'')?>> <?=$lang_acp['true']?> <input type=radio class=checkbox value=0 name=<?=$name?><?=((!$mod_permission[$name])?' checked':'')?>> <?=$lang_acp['false']?> </td>
</tr>
<?php
}
?>
<tr><td class=fr colspan=2 align=center><input type=submit name=submit class=submit value=Submit></td></tr>
</table>
</form>
<?php
}
else {
	$per = '';
	foreach ($permission_list as $name => $desc) {
		$v = $_POST[$name];
		if ($v == '') $v = 0;
		$per .= $v;
	}
	$per = bindec($per);
	$DB->query("UPDATE ".$conf['prefix']."config SET config_value = '".$per."' WHERE config_name = 'mod_permission'");
	echo $lang_acp['edited']." <meta http-equiv='refresh' content='0;url=$link'>";
}
?>